<template>
	<view class="menu">
		<view class="list">
			<view class="list-item" @tap="addFriend">
				添加好友
			</view>
			<view class="list-item" @tap="qrCode">
				扫一扫
			</view>
			<view class="list-item" @tap="more">
				更多功能
			</view>
			<!-- <view class="list-item" @tap="assistant">
				智能助手
			</view> -->
			<!-- <view class="list-item" @tap="test">
				QR
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		tobeOrNot

	} from "../../api/register/index.js"
	export default {
		name: "menu-list",
		data() {
			return {
				data: "",
			}
		},
		methods: {
			addFriend() {
				uni.navigateTo({
					url: "/pages/search/search",
				})
			},
			assistant() {
				uni.navigateTo({
					url: "/pages/assistant/assistant"
				})
			},
			qrCode() {
				uni.scanCode({
					success: (scanRes) => {
						//用户如果扫描的不是用户的id 或者在数据库中没有这个用户 则将错误的信息传到testQrcode页面
						tobeOrNot({
							id: scanRes.result
						}).then(res => {
							console.log(res.data.status, "是否收到返回结果");
							console.log(scanRes.result, "是否收到QR结果");
							if (res.data.status == 200) {
								uni.navigateTo({
									url: "/pages/userGarllery/userGarllery?id=" + scanRes
										.result
								})
							} else {
								uni.navigateTo({
									url: "/pages/testQrcode/testQrcode?id=" + scanRes.result
								})
							}
						})
					}
				})
			},
			test() {
				uni.navigateTo({
					url: "/pages/testQrcode/testQrcode?id=" + 1231232321
				})
			},
			more() {
				uni.navigateTo({
					url: "/pages/testrecording/testrecording"
				})
			}

		}
	}
</script>

<style lang="scss">
	.menu {
		position: absolute;
		top: 70rpx;
		left: -150rpx;
		width: 200rpx;
		border-radius: 8rpx;
		background-color: #ffed47;

		.list {
			width: 100%;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			font-size: 28rpx;

			.list-item {
				text-align: center;
				height: 44rpx;
				width: 120rpx;
				padding: 8rpx;
				overflow: hidden;

				&:not(:last-child) {
					border-bottom: 2rpx solid #a88d8d;
				}

			}
		}

		&::after {
			content: "";
			display: block;
			width: 0px;
			height: 0px;
			position: absolute;
			left: 140rpx;
			top: -50rpx;
			z-index: -1;
			border-bottom: 30rpx solid #0f0f32;
			border-top: 30rpx solid transparent;
			border-right: 30rpx solid transparent;
			border-left: 30rpx solid transparent;
		}
	}
</style>